home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Utils / SelectMode / Main.C < prev    next >
C/C++ Source or Header  |  1996-06-25  |  3KB  |  129 lines

  1. /*
  2.  
  3.   Select Mode (C) 1995 Dominic Clifton - Aka Hydra/LSD - Deluxe Software Ltd!
  4.  
  5.   Defines a screenmode for HBBS to use!
  6.  
  7. */
  8.  
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <stdio.h>
  12. #include <ctype.h>
  13. #include <time.h>
  14.  
  15. #include <exec/types.h>
  16. #include <exec/memory.h>
  17.  
  18. #include <libraries/reqtools.h>
  19.  
  20. #include <clib/exec_protos.h>
  21. #include <clib/reqtools_protos.h>
  22.  
  23. #include <HBBS/ANSI_Codes.h>
  24. #include <HBBS/Defines.h>
  25. #include <HBBS/types.h>
  26. #include <HBBS/structures.h>
  27. #include <HBBS/hbbscommon_protos.h>
  28. #include <HBBS/hbbscommon_pragmas.h>
  29.  
  30. struct Library *HBBSCommonBase=NULL;
  31. struct ReqToolsBase *ReqToolsBase;
  32.  
  33. UBYTE *OPT_BBS_ScrModeID           = "ScrModeID",
  34.       *OPT_BBS_ScrWidth            = "ScrWidth",
  35.       *OPT_BBS_ScrHeight           = "ScrHeight",
  36.       *OPT_BBS_ScrDepth            = "ScrDepth";
  37.  
  38. UBYTE *FILE_SCRMODEPREFS           = "HBBS:System/Data/CtrlScrPrefs.CFG";
  39.  
  40. static VOID cleanup(ULONG num)
  41. {
  42.   if (ReqToolsBase)
  43.     CloseLibrary ((struct Library *)ReqToolsBase);
  44.  
  45.   if (HBBSCommonBase)
  46.   {
  47.     HBBS_CleanUpCommon();
  48.     CloseLibrary (HBBSCommonBase);
  49.   }
  50.  
  51.  
  52.   if (num) printf("Door Error = %d\n",num);
  53.  
  54.   exit(0);
  55. }
  56.  
  57. static VOID init( void )
  58. {
  59.   if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
  60.   {
  61.     cleanup(1);
  62.   }
  63.  
  64.   if (!(HBBS_InitCommon()))
  65.   {
  66.     cleanup(2);
  67.   }
  68.  
  69.   if (!(ReqToolsBase = (struct ReqToolsBase *) OpenLibrary (REQTOOLSNAME, REQTOOLSVERSION)))
  70.   {
  71.     cleanup(3);
  72.   }
  73.  
  74. }
  75.  
  76. BOOL PickScreen( void )
  77. {
  78.   BOOL retval=FALSE;
  79.   struct rtScreenModeRequester *scrmodereq;
  80.   struct CfgFileData *ScrCfg;
  81.   char params[30];
  82.  
  83.   if (scrmodereq = rtAllocRequestA (RT_SCREENMODEREQ, NULL))
  84.   {
  85.     if (rtScreenModeRequest (scrmodereq, "Select Screen mode:",RTSC_Flags,SCREQF_GUIMODES | SCREQF_DEPTHGAD | SCREQF_SIZEGADS,
  86.                                                                RTSC_MinHeight,200,
  87.                                                                RTSC_MinWidth,640,
  88.                                                                RTSC_MinDepth,2,
  89.                                                                RTSC_MaxDepth,4,
  90.  
  91.                                                                TAG_END))
  92.     {
  93.  
  94.       if (ScrCfg=HBBS_CreateConfig((FILE_SCRMODEPREFS)))
  95.       {
  96.         sprintf(params,"%d",scrmodereq->DisplayID);
  97.         HBBS_AddCfgItem(ScrCfg,OPT_BBS_ScrModeID,params);
  98.         sprintf(params,"%d",scrmodereq->DisplayHeight);
  99.         HBBS_AddCfgItem(ScrCfg,OPT_BBS_ScrHeight,params);
  100.         sprintf(params,"%d",scrmodereq->DisplayWidth);
  101.         HBBS_AddCfgItem(ScrCfg,OPT_BBS_ScrWidth,params);
  102.         sprintf(params,"%d",scrmodereq->DisplayDepth);
  103.         HBBS_AddCfgItem(ScrCfg,OPT_BBS_ScrDepth,params);
  104.  
  105.         if (!HBBS_SaveConfig(ScrCfg))
  106.         {
  107.           HBBS_rterror("Error Saving Screenmode Prefs!");
  108.         }
  109.         else
  110.         {
  111.           retval=TRUE;
  112.         }
  113.         HBBS_FlushConfig(ScrCfg);
  114.       }
  115.     }
  116.     rtFreeRequest(scrmodereq);
  117.   }
  118.   return(retval);
  119. }
  120.  
  121. void main( void )
  122. {
  123.   init();
  124.  
  125.   PickScreen();
  126.  
  127.   cleanup(0);
  128. }
  129.